#!/usr/bin/env python
import sys
import helper
import class_set
from sets import Set

class FilterReducer(helper.ReducerHelper):
    """
    filter result   
    """
    def processor(self, key, lst):
        clean = False
        left, right = self.split(key)
        # don't allow self-recommendation, e.g. A <-> A
        if left == right:
            return

        for e in lst:
            recom_tag = class_set.RecomTag('')
            recom_tag.init(e)
            # find whether there is filter or not
            if recom_tag.isType('filter'):
                clean = True
                break

        if clean is False:
            for e in lst:
                self.allocator(key, e)
        
def main():
    fr = FilterReducer()
    fr.reducer()

if __name__ == '__main__':
    main()

